package com.purebang.spaceinvaders;

import java.awt.Rectangle;

public class MysteryShip {

	public enum MoveDirection {
		right,
		left
	};
	
	public static final int SHIP_WIDTH = 60;
	public static final int SHIP_HEIGHT = 20;
	
	private Rectangle hitbox;
	private int score;
	private int xSpeed = 3;
	private MoveDirection direction;
	private boolean escaped = false;
	
	public MysteryShip (int x, int y, int score, MoveDirection direction) {
		hitbox = new Rectangle(x, y, SHIP_WIDTH, SHIP_HEIGHT);
		this.score = score;
		this.direction = direction;
	}
	
	public void update() {
		if(direction == MoveDirection.left && (hitbox.x + SHIP_WIDTH) > 0) {
			hitbox.x = hitbox.x - xSpeed;
		}else if(direction == MoveDirection.left && (hitbox.x + SHIP_WIDTH) <= 0) {
			escaped = true;
		}
		
		if(direction == MoveDirection.right && hitbox.x < GameManager.LEVEL_WIDTH) {
			hitbox.x = hitbox.x + xSpeed;
		}else if (direction == MoveDirection.right && hitbox.x >= GameManager.LEVEL_WIDTH) {
			escaped = true;
		}
	}
	
	public boolean isEscaped() {
		return escaped;
	}
	
	public int getScore() {
		return score;
	}
	
	public Rectangle getHitbox() {
		return hitbox;
	}
		
}
